package com.qf.fmcommodity.user.controller;

import com.qf.fmcommodity.user.entity.ProductParams;
import com.qf.fmcommodity.user.service.IProductCommentsService;
import com.qf.fmcommodity.user.service.IProductParamsService;
import com.qf.fmcommodity.user.service.IProductService;
import com.qf.fmcommodity.user.vo.LoginVo;
import com.qf.fmcommodity.user.vo.ProSkuImgVo;
import com.qf.fmcommodity.user.vo.Total;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * <p>
 * 商品 商品信息相关表：分类表，商品图片表，商品规格表，商品参数表 前端控制器
 * </p>
 *
 * @author 苇名一心
 * @since 2023-02-13
 */
@RestController
@RequestMapping("/product")
@CrossOrigin
public class ProductController {

    @Autowired
    IProductService iProductService;

    @Autowired
    IProductParamsService iProductParamsService;

    @Autowired
    IProductCommentsService iProductCommentsService;

    @GetMapping("/detail-commonts/{id}")
    public LoginVo detailCommonts(@PathVariable("id") Integer id,Integer pageNum,Integer limit){

        Map<String,Object> data = iProductCommentsService.detailCommonts(id,pageNum,limit);

        LoginVo vo = new LoginVo();

        vo.put("data",data);

        return vo;

    }

    @GetMapping("/detail-params/{id}")
    public LoginVo detailParams(@PathVariable("id") Integer id){
        ProductParams data = iProductParamsService.detailParams(id);

        LoginVo vo = new LoginVo();
        vo.put("data",data);

        return vo;
    }

    @GetMapping("/detail-info/{id}")
    public LoginVo detailInfo(@PathVariable("id") Integer id){

        ProSkuImgVo data = iProductService.detailInfo(id);

        LoginVo vo = new LoginVo();
        vo.put("data",data);
        return vo;
    }

    @GetMapping("/detail-commontscount/{id}")
    public LoginVo detailCommontscount(@PathVariable("id") Integer id){

        Total data =  iProductCommentsService.detailCommontscount(id);

        LoginVo vo = new LoginVo();
        vo.put("data",data);
        return vo;
    }

}
